/*
 #define PHASE_1_A 1
 #define PHASE_1_B 2
 #define PHASE_2_A 3
 #define PHASE_2_B 4
 #define	MULTICAST_FORWARD	  5
 //------------------------------------------------------------------------------
 typedef struct connection connection;
 typedef struct msg_t msg;
 #define MAX_MSG_COUNT 1//((MAX_PACKET_SIZE) - (6*sizeof(int))-(4*sizeof(bool)))/( sizeof(msg)+2)
 //------------------------------------------------------------------------------
 typedef struct pack_t pack;
 typedef struct inst_t inst;
 typedef struct paxos_data_t paxos_data;
 typedef struct paxos_msg_t paxos_msg;
 typedef struct result_t result;
 typedef struct gap_t gap;

 */

#include	<stdio.h>
#include	<string.h>
#include	<stdlib.h>
#include	<stdbool.h>
#include	<unistd.h>
#include	<assert.h>

#define PHASE_1_A 1
#define PHASE_1_B 2
#define PHASE_2_A 3
#define PHASE_2_B 4

#define	MULTICAST_FORWARD	  5
//------------------------------------------------------------------------------
typedef struct proposer_msg_t {
	int node_id;
	int msg_id;
	int location_in_proposer;
	double microseconds;
	char delivered; //n, y
	char fake[8552]; //8252  //8552 + 14/1000 = 870
} proposer_msg;

#define	PROPOSER_MSG_HEADER_SIZE (3 * sizeof(int) + sizeof(double) + sizeof(char))

#define MAX_MSG_COUNT 1//((MAX_PACKET_SIZE) - (6*sizeof(int))-(4*sizeof(bool)))/( sizeof(msg)+2)
//------------------------------------------------------------------------------
typedef struct pack_t {
	int pack_id;
	proposer_msg msgs[MAX_MSG_COUNT];
} pack;
//------------------------------------------------------------------------------
typedef struct inst_t {
	pack packet;
	bool deliver;
	bool received;

	int instance_id;
	int coordinator_id;
	int dec;
	int round_number;
	int highestDeliverable;

} inst;
//------------------------------------------------------------------------------
typedef struct paxos_data_t {
	int rnd;
	int vrnd;
	int vval;

	int crnd;
	int cval;

} paxos_data;
//------------------------------------------------------------------------------
typedef struct paxos_msg_t {

	int instance_number;
	int round_number;
	int acceptor_count;
	int type;

	int max_vrnd;
	int max_vval;
	int VALUE;

} paxos_msg;
//------------------------------------------------------------------------------

typedef struct gap_t {
	int start;
	int end;
} gap;
